<script lang='tsx'>
import { Prop, Provide, Emit, Watch, Model } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { AppMenusCtrlBase } from '@/crm-core';
import AppIndexViewService from './app-index-view-appmenu-service';

import AppIndexViewModel from './app-index-view-appmenu-model';


/**
 * 应用首页视图默认菜单基类
 *
 * @export
 * @class AppIndexViewBase
 * @extends {AppMenusCtrlBase}
 */
export default class AppIndexViewBase extends AppMenusCtrlBase {

    /**
     * 建构部件服务对象
     *
     * @type {AppIndexViewService}
     * @memberof AppIndexView
     */
    public service: AppIndexViewService = new AppIndexViewService({ $store: this.$store });

    /**
     * 菜单对齐方向
     *
     * @type {CrmIndexService}
     * @memberof CrmIndex
     */
    protected menuAlign: string = 'LEFT';

    /**
     * 菜单模型
     *
     * @protected
     * @type {AppIndexViewModel}
     * @memberof AppIndexView
     */
    protected menuModel: AppIndexViewModel = new AppIndexViewModel();

    /**
     * 触发方式，默认click
     *
     * @type {string}
     * @memberof AppIndexView
     */
    @Provide()
    public trigger: string = 'click';

    /**
     * 菜单点击
     *
     * @protected
     * @param {*} item 菜单数据
     * @memberof AppIndexView
     */
    protected click(item: any) {
        if (item) {
            switch (item.appfunctag) {
                case 'Auto21': 
                    this.clickAuto21(item);
                    return;
                case 'Auto32': 
                    this.clickAuto32(item);
                    return;
                case 'Auto3': 
                    this.clickAuto3(item);
                    return;
                case 'Auto35': 
                    this.clickAuto35(item);
                    return;
                case 'Auto37': 
                    this.clickAuto37(item);
                    return;
                case 'Auto41': 
                    this.clickAuto41(item);
                    return;
                case 'Auto34': 
                    this.clickAuto34(item);
                    return;
                case 'Auto2': 
                    this.clickAuto2(item);
                    return;
                case 'Auto10': 
                    this.clickAuto10(item);
                    return;
                case 'Auto27': 
                    this.clickAuto27(item);
                    return;
                case 'Auto17': 
                    this.clickAuto17(item);
                    return;
                case 'Auto44': 
                    this.clickAuto44(item);
                    return;
                case 'Auto15': 
                    this.clickAuto15(item);
                    return;
                case 'Auto46': 
                    this.clickAuto46(item);
                    return;
                case 'Auto24': 
                    this.clickAuto24(item);
                    return;
                case 'Auto6': 
                    this.clickAuto6(item);
                    return;
                case 'Auto23': 
                    this.clickAuto23(item);
                    return;
                case 'Auto1': 
                    this.clickAuto1(item);
                    return;
                case 'Auto7': 
                    this.clickAuto7(item);
                    return;
                case 'Auto18': 
                    this.clickAuto18(item);
                    return;
                case 'Auto5': 
                    this.clickAuto5(item);
                    return;
                case 'Auto14': 
                    this.clickAuto14(item);
                    return;
                case 'Auto45': 
                    this.clickAuto45(item);
                    return;
                case 'Auto47': 
                    this.clickAuto47(item);
                    return;
                case 'Auto36': 
                    this.clickAuto36(item);
                    return;
                case 'Auto39': 
                    this.clickAuto39(item);
                    return;
                case 'Auto33': 
                    this.clickAuto33(item);
                    return;
                case 'Auto8': 
                    this.clickAuto8(item);
                    return;
                case 'Auto26': 
                    this.clickAuto26(item);
                    return;
                case 'Auto31': 
                    this.clickAuto31(item);
                    return;
                case 'Auto22': 
                    this.clickAuto22(item);
                    return;
                case 'Auto20': 
                    this.clickAuto20(item);
                    return;
                default:
                    console.warn('未指定应用功能');
            }
        }
    }
    /**
     * 打开iBiz开发平台
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto21(item: any = {}){
       const localdata: any = this.$store.getters.getLocalData();
       const url = `https://www.ibizlab.cn/`;
       window.open(url, '_blank');
    }
    
    /**
     * 全部商机
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto32(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'crm_leads', parameterName: 'crm_lead' },
            { pathName: 'allleadtreeexpview', parameterName: 'allleadtreeexpview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 销售订单
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto3(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'sale_orders', parameterName: 'sale_order' },
            { pathName: 'gridview', parameterName: 'gridview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 公司领导
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto35(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'leaderportalview', parameterName: 'leaderportalview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 我的团队导览
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto37(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'crm_teams', parameterName: 'crm_team' },
            { pathName: 'dataviewexpview2', parameterName: 'dataviewexpview2' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 客户动态导览
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto41(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'res_partners', parameterName: 'res_partner' },
            { pathName: 'dataviewexpview', parameterName: 'dataviewexpview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 团队商机
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto34(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'crm_leads', parameterName: 'crm_lead' },
            { pathName: 'salespersontreeexpview', parameterName: 'salespersontreeexpview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 发票
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto2(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'account_invoices', parameterName: 'account_invoice' },
            { pathName: 'gridview', parameterName: 'gridview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 产品种类
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto10(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'product_categories', parameterName: 'product_category' },
            { pathName: 'gridview', parameterName: 'gridview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 工作台
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto27(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'appportalview', parameterName: 'appportalview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 功能名称
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto17(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'res_users', parameterName: 'res_users' },
            { pathName: 'gridview', parameterName: 'gridview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 产品信息
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto44(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'product_products', parameterName: 'product_product' },
            { pathName: 'gridview', parameterName: 'gridview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 付款登记
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto15(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'account_payments', parameterName: 'account_payment' },
            { pathName: 'gridview', parameterName: 'gridview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 商机导航
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto46(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'crm_leads', parameterName: 'crm_lead' },
            { pathName: 'gridexpview', parameterName: 'gridexpview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 客户树
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto24(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'res_partners', parameterName: 'res_partner' },
            { pathName: 'treeexpview', parameterName: 'treeexpview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 合同信息
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto6(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'product_pricelists', parameterName: 'product_pricelist' },
            { pathName: 'gridview', parameterName: 'gridview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 销售人员（销售团队树人员）
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto23(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'res_users', parameterName: 'res_users' },
            { pathName: 'treeexpview', parameterName: 'treeexpview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 销售团队
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto1(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'crm_teams', parameterName: 'crm_team' },
            { pathName: 'gridview', parameterName: 'gridview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 账单
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto7(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'account_invoices', parameterName: 'account_invoice' },
            { pathName: 'usr2gridview', parameterName: 'usr2gridview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    /**
     * 打开项目地址gitee
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto18(item: any = {}){
       const localdata: any = this.$store.getters.getLocalData();
       const url = `https://gitee.com/iBizOdoo`;
       window.open(url, '_blank');
    }
    
    /**
     * 客户信息
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto5(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'res_partners', parameterName: 'res_partner' },
            { pathName: 'gridview', parameterName: 'gridview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    /**
     * 打开iBiz论坛
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto14(item: any = {}){
       const localdata: any = this.$store.getters.getLocalData();
       const url = `https://bbs.ibizlab.cn/`;
       window.open(url, '_blank');
    }
    /**
     * 打开移动端地址
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto45(item: any = {}){
       const localdata: any = this.$store.getters.getLocalData();
       const url = `http://odoo.ibizlab.cn/mob`;
       window.open(url, '_blank');
    }
    
    /**
     * 销售活动日历
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto47(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'calendar_events', parameterName: 'calendar_event' },
            { pathName: 'calendarexpview', parameterName: 'calendarexpview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 我的联系人
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto36(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'res_partners', parameterName: 'res_partner' },
            { pathName: 'contactscardview', parameterName: 'contactscardview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    /**
     * 打开配置工具
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto39(item: any = {}){
       const localdata: any = this.$store.getters.getLocalData();
       const url = `http://studio.ibizlab.cn/slnstudio/#/common_slnindex/srfkeys=59A09D84-2808-4BEF-AF96-8C67ED75C611/sysdesign_psdevslncurusersystreeexpview`;
       window.open(url, '_blank');
    }
    
    /**
     * 销售员工作台
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto33(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'salespersonportalview', parameterName: 'salespersonportalview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 报价单
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto8(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'sale_orders', parameterName: 'sale_order' },
            { pathName: 'usr2gridview', parameterName: 'usr2gridview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 团队负责人人工作台
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto26(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'teamleaderportalview', parameterName: 'teamleaderportalview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 我的商机
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto31(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'crm_leads', parameterName: 'crm_lead' },
            { pathName: 'leadcardview', parameterName: 'leadcardview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 销售团队导览
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto22(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'crm_teams', parameterName: 'crm_team' },
            { pathName: 'dataviewexpview', parameterName: 'dataviewexpview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }
    
    /**
     * 团队客户
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public clickAuto20(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'res_partners', parameterName: 'res_partner' },
            { pathName: 'salespersontreeexpview', parameterName: 'salespersontreeexpview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        this.$router.push(path);
    }

    public render(): any {
        return (
            <div class="app-app-menu">
                <app-menus menuAlign={this.menuAlign} menus={this.menus} on-menu-click={(item: any) => this.click(item)}/>
            </div>
        );
    }
    
}
</script>

<style lang='less'>
@import './app-index-view-appmenu.less';
</style>